package com.gxa.modules.pc.hospital.controller;

import com.gxa.common.utils.PageUtils;
import com.gxa.common.utils.Result;
import com.gxa.modules.pc.hospital.service.DoctorLabelService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

import java.lang.reflect.Array;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 医生职称 前端控制器
 * </p>
 *
 * @author gxa
 * @since 2022-11-12 05:04:59
 */
@Api(tags = "职称管理")
@RestController
@RequestMapping("/doctor-label")
public class DoctorLabelController {

    @Autowired
    private DoctorLabelService doctorLabelService;

    @ApiOperation(value="职称分页查询接口")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query",name = "page",value ="当前是第几页",dataType ="int"),
            @ApiImplicitParam(paramType = "query",name = "limit",value ="每页显示多少条",dataType ="int"),
            @ApiImplicitParam(paramType = "query",name = "name",value ="职称名称",dataType ="String"),
            @ApiImplicitParam(paramType = "query",name = "order",value ="升序asc，降序填desc",dataType ="String"),
            @ApiImplicitParam(paramType = "query",name = "sidx",value ="排序字段",dataType ="String"),

    }
    )
    @GetMapping("/select")
    public Result<PageUtils> select(@RequestParam @ApiIgnore Map<String , Object> params){
        PageUtils pageUtils = this.doctorLabelService.queryByPage(params);
        return new Result<PageUtils>().ok(pageUtils);
    }

    @ApiOperation(value="职称增加接口")
    @PostMapping("/add")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query",name = "name",value ="职称名称",dataType ="String"),
            @ApiImplicitParam(paramType = "query",name = "price",value ="挂号费",dataType ="double"),
            @ApiImplicitParam(paramType = "query",name = "titledescribe",value ="职称描述",dataType ="String"),
    }
    )
    public Result add(@RequestParam @ApiIgnore Map<String , Object> params){
        try {
            this.doctorLabelService.addTitle(params);
            return new Result().ok();
        } catch (Exception e) {
            e.printStackTrace();
            return new Result().error();
        }
    }
    @ApiOperation(value="职称删除接口")
    @DeleteMapping("/delete")
    public Result delete(@RequestBody int[] list){
        try {
            this.doctorLabelService.deleteByList(list);
            return new Result().ok();
        } catch (Exception e) {
            e.printStackTrace();
            return new Result().error();
        }
    }

}
